package com.github.sbb.sherry.console.controller.engine.config;


import com.github.sbb.sherry.console.dto.PageList;
import com.github.sbb.sherry.console.service.engine.config.RulesEngineConfigService;
import com.github.sbb.sherry.repository.entity.RulesEngine;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("engine/config/rulesEngine")
public class RulesEngineConfigController {

  @Autowired
  private RulesEngineConfigService rulesEngineConfigService;

  @GetMapping("pageList")
  public PageList<RulesEngine> pageList(int currentPage, Integer pageSize) {
    return rulesEngineConfigService.pageList(currentPage, pageSize);
  }

  @GetMapping("/{id}")
  public RulesEngine getById(@PathVariable("id") int id) {
    return rulesEngineConfigService.getById(id);
  }

  @PostMapping("add")
  public void add(@RequestBody RulesEngine rulesEngine) {
    rulesEngineConfigService.add(rulesEngine);
  }

  @PostMapping("changeEngineExpansionConfig")
  public void changeEngineExpansionConfig(@RequestBody RulesEngine rulesEngine) {
    rulesEngineConfigService.changeEngineExpansionConfig(rulesEngine);
  }
}
